﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Jxym.DBUtility;

namespace Jxym.wlkc2011.Module.Default.server.Nation
{
    public partial class NationList : System.Web.UI.Page
    {
        private string jsonStr;
        private int _id;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                MsSqlDal<model.Nation> mnation = new MsSqlDal<model.Nation>();
                if (Request.Params["id"] == null)
                {
                    IList<model.Nation> mnationList = mnation.GetList("", null, "", 0);
                    jsonStr = "[";
                    foreach (model.Nation info in mnationList)
                    {
                        jsonStr += "{'ID':" + info.ID + ",'Name':'" + info.Title + "'},";
                    }
                    jsonStr = jsonStr.TrimEnd(',') + "]";
                }
                else
                {
                    _id = Convert.ToInt32(Request.Params["id"]);
                    model.Nation info = mnation.GetModel("ID=" + _id, null);
                    jsonStr = "{'ID':" + info.ID + ",'Name':'" + info.Title + "'}";
                }
                Response.Write(jsonStr);
            }
        }
    }
}